package com.youpingou.controller;

import com.youpingou.service.SkuService;
import com.youpingou.vo.BaseResult;
import com.youpingou.vo.OneSkuResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * @auther Created by yuanxinqi
 */
@RestController
@RequestMapping
public class SkuController {

    @Autowired
    private SkuService skuService;

    @GetMapping("/goods/{skuid}")
    public BaseResult findSkuBySkuId(@PathVariable("skuid") Integer skuid){
        // 调用service层查找数据
        OneSkuResult sku = skuService.findSkuBySkuId(skuid);
        // 组装信息
        return BaseResult.ok(sku);
    }

    @PutMapping("/goods/{skuid}/{count}")
    public void updateSkuCount(@PathVariable("skuid") Integer skuid,
                               @PathVariable("count") Integer count){

        skuService.updateSku(skuid,count);
    }




}